# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer:
pkgname=cargo-patch
pkgver=0.1.10
pkgrel=2
pkgdesc="Cargo subcommand for patching dependencies using patch files"
url="https://github.com/mettke/cargo-patch"
arch="aarch64 armhf armv7 ppc64le x86 x86_64"  # blocked by rust/cargo
license="MIT"
depends="cargo"
makedepends="
	curl-dev
	libgit2-dev
	libssh2-dev
	openssl-dev
	"
options="!check" # TODO: Test failure with libgit2 1.4.2
source="https://github.com/mettke/cargo-patch/archive/v$pkgver/cargo-patch-$pkgver.tar.gz"

export LIBSSH2_SYS_USE_PKG_CONFIG=1  # use system libssh2

prepare() {
	default_prepare

	# Optimize binary for size.
	cat >> Cargo.toml <<-EOF

		[profile.release]
		codegen-units = 1
		lto = true
		opt-level = "z"
		panic = "abort"
	EOF
	cargo fetch --locked
}

build() {
	cargo build --frozen --release
}

check() {
	cargo test --frozen
}

package() {
	install -D -m755 target/release/cargo-patch -t "$pkgdir"/usr/bin/
}

sha512sums="
d95468941954e765a5fa65afce31acfef8fea228c73002e3fe78aa14cfd360ab2d2ee9150032f327d0e5e5631f000859216282a200695256a0a600c9c7f72659  cargo-patch-0.1.10.tar.gz
"
